package eight.test_8_11;

import java.util.Scanner;

public class TestMain3 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[][] arr = new int[n][2];
        int count = 0;
        int sy = 0;
        int cs = 1;
        for (int i = 0; i < n; i++) {
            arr[i][0] = scanner.nextInt();
            arr[i][1] = scanner.nextInt();
        }
        for (int i = 1; i < n - 1; i++) {
           int t1 = arr[i - 1][0];
           int t2 = arr[i][0];
           int t3 = arr[i + 1][0];
           if(t1 - t2 >= arr[i - 1][1] && sy == 0) {
               count += arr[i - 1][1];
           }else if(t1 - t2 + sy < arr[i - 1][1]) {
               sy += (arr[i - 1][1] - (t1 - t2));
               cs++;
               if(sy <= t1 - t2) {
                   sy = 0;
                   cs = 0;
               } else {

               }
           }
        }
        System.out.println(count);
    }
}
